# -*- encoding: utf-8 -*-
"""
File Name: spider_monitor_pipline
Description:
Author : 'lirui'
date: 10/24/2024
Contact: marjey_lee@163.com
Change Activity:
10/24/2024:
"""
import ll
from projects.monitoring.common.utils.redis_keys_util import RedisKeysUtil
from projects.monitoring.common.workflow.monitoring_pipline_interface import MonitorPipLineInterface


class SpiderMonitorPipline(MonitorPipLineInterface):
    _MONITORING_TYPE = RedisKeysUtil.get_spider_monitor_publisher_keys()

    def _format_alarms(self, original_alarms):
        return original_alarms

    def __init__(self):
        super().__init__(self._MONITORING_TYPE)

    def _load_original_alarms(self):
        ll.get_logger().info('Start to load problems from zabbix server.')
        problems = get_external_zabbix_server_problems()
        ll.get_logger().info(
            f'Load problems from zabbix server finished, total problems count {len(problems)}.'
        )
        return problems
